package event;

import model.symbol.Symbol;

/**
 * This is for events in which a {@link Symbol} is renamed.
 *
 * Authors: Neil Dickson
 */
public class SymbolRenameEvent extends SymbolChangeEvent {
	private	String	oldName;
	private	String	newName;

	public SymbolRenameEvent(Symbol symbol, String oldName, String newName) {
		super(symbol);
		this.oldName = oldName;
		this.newName = newName;
	}

	public Undoable undo() {
		symbol.getName().replaceAll(oldName);
		return new SymbolRenameEvent(symbol,newName,oldName);
	}

	public String getDescription() {
		return "Rename "+oldName+" to "+newName;
	}

	public String getOldName() {
		return oldName;
	}

	public String getNewName() {
		return newName;
	}
}
